import random

def generate_numbers():
    """生成1个包含8个1-33不重复整数的中奖号码"""
    return sorted(random.sample(range(1, 34), 8))

def calculate_prize(user, system):
    """计算中奖等级"""
    correct = len(set(user) & set(system))
    errors = 8 - correct
    if errors == 0:
        return "一等奖"
    elif errors == 1:
        return "二等奖"
    elif errors == 2:
        return "三等奖"
    elif errors == 3:
        return "四等奖"
    else:
        return "未中奖"

# 用户输入处理
user_input = eval(input("请输入8位数字（由逗号隔开）："))

# 生成并显示系统中奖号码
system_numbers = generate_numbers()
print("\n系统生成的中奖号码：", ' '.join(map(str, system_numbers)))
print("您的号码：", ' '.join(map(str, user_input)))

# 判断用户中奖结果
prize = calculate_prize(user_input, system_numbers)
print(f"\n中奖结果：{prize}")

# 模拟购买10000注彩票
stats = {0: 0, 1: 0, 2: 0, 3: 0}
for _ in range(10000):
    ticket = generate_numbers()
    errors = 8 - len(set(ticket) & set(user_input))
    if errors <= 3:
        stats[errors] += 1
    else:
        0

# 显示中奖概率
print("\n模拟10000注彩票的中奖概率：")
for error, count in stats.items():
    if error < 4:
        level = ["一等奖", "二等奖", "三等奖", "四等奖"][error]
    else:
        "无奖"
    print(f"{level}: {count/10000 * 100:.2f}%")